


The (Local) Valley of Fear

by Bitenomnom



Series: Mathematical Proof [30]
Category: Sherlock (TV)
Genre: Ambiguous Relationship Status, Angst, Friendship, Kissing, Love, M/M, Mathematics, Post-Reichenbach, Pre-Reichenbach
Language: English
Status: Completed
Published: 2012-10-31
Updated: 2012-10-31
Packaged: 2017-11-17 11:04:17
Rating: Not Rated
Warnings: Creator Chose Not To Use Archive Warnings
Chapters: 1
Words: 2,024
Publisher: archiveofourown.org
Story URL: https://archiveofourown.org/works/550872
Author URL: https://archiveofourown.org/users/Bitenomnom/pseuds/Bitenomnom
Summary: <blockquote class="userstuff">
              <p>When Sherlock gets stuck inside his mind palace, John must discover a way to free him from it.</p>
            </blockquote>





	The (Local) Valley of Fear

**Author's Note:**

> Disclaimer: I haven't actually read The Valley of Fear. This isn't meant to imitate it.  
> Also: I wrote this in, like, less than an hour, around 4-5am, possibly amidst slight amounts of drinking, after several hours of working on [The Case of the Louisiana Lake](http://archiveofourown.org/works/550818), so I am really sorry for any typos or nonsensical bits.

Newton’s descent method, also known as a gradient search, is a different method of soft computing, complementary to the genetic algorithm (GA) (see [The Genetic Algorithm](http://archiveofourown.org/works/546328)). Where the GA performs a slow, global search, gradient searching performs a fast, local search.

 

Imagine a topographical math with, say, a valley in a particular area. In the gradient search, one finds the contour lines—the continuous areas of the topographical map where the height is the same—and from one’s starting point, finds a tangent line to that contour. Then, one checks whether one descends more quickly perpendicular to the tangent line on one side or the other, and picks that direction, and then goes that way until one is tracing the tangent line of another contour. At this point, one stops, and this location becomes the new “starting point.” The same procedure is performed over and over until the lowest point is reached.

  
The problem with this method is that it is a local search, and therefore there is the risk of falling into a valley. It may _seem_ like the minimum, but you have no way of knowing whether it is the global minimum (the very smallest number in the entire scenario) or just the local one (maybe just a small valley you happen to get trapped in).

 

This method also requires that the function is differentiable everywhere. However, in many problems, this is not the case. So, instead, the pseudo gradient search was formulated. Here, the difference is used to replace the differential (slope), so you don’t necessarily need a differentiable function—just a continuous one. The procedure in pseudo gradient searching involves taking very small steps and determining the best direction to take based on these. If the value gets better (smaller) after one small step, one takes a bigger step, and a bigger one, for as long as the value keeps getting better—but then once you “overstep” it and have to turn around, you take smaller and smaller steps. Once you’ve reached the size of the original step, this point is your new initial point, and you start the procedure again.

 

Perhaps the ideal method of searching involves using a combination of GA and pseudo gradient searching. One can use the GA to find a good general point globally (so there is not the risk of falling into local valleys), and then use pseudo gradient searching to hone in on that point. Careful, though: while GA can be used for both numerical and categorical objective functions (the thing you want to make the smallest or largest possible), pseudo gradient cannot be used for categorical/discrete objective functions.

 

***  


            Sherlock had been in the exact same position on the sofa for the past—by John’s reckoning—eighteen hours.

            It was his usual practice not to bother Sherlock when he got like this, usually because he sorely regretted it later, but this was getting a bit ridiculous.

            “Sherlock,” John said, shutting his laptop. “Sherlock, okay, it’s time to get up. Get something to eat, use the loo, I dunno.”

            Sherlock was unresponsive.

            What that probably meant was that he was in his mind palace. John crossed his arms and paced across the sitting room a few times, thoughtfully. Sherlock specifically requested John not bother him while he was in his mind palace—and John was inclined to listen to him on this point; he wouldn’t be responsible for perturbing anything in there. Was it like a flash drive, where you could yank it from the port without warning so many times but always ran the risk of plugging it back in to find all your files gone? Sherlock’s mind was like John’s gun, and John could at least be as respectful of Sherlock as he wished Sherlock would be to his own things. His mind was all but sacred, after all.

            “Sherlock,” John said again, more loudly, and gently reached out to touch his hand. Nothing.

            He considered calling up someone who’d know better—Mycroft? Lestrade?—and ask if this had happened before. But Mycroft was about the last person on earth he wanted to talk to, and probably hadn’t even the slightest idea how to help Sherlock without being unbearably obtrusive; Greg had already insisted, more than once, that from the second day Sherlock and John knew each other, John knew Sherlock better than Greg ever would. Mrs. Hudson would probably panic—and there was no reason to worry her over this, not when there was nothing she could do about it.

            So John was on his own for this one.

            He sat down on the sofa beside Sherlock’s feet. “Look, Sherlock, I don’t know if you can hear me, but you need to get up and move around.” He waited for a moment, looking for a response, and then added, “You can’t possibly be doing something so important in there that you can’t come out for a little bit. Just to make me feel better, all right?”

            Nothing.

            He could try being extremely noisy, could try bodily moving Sherlock from his reclined position. But that seemed—crude, and there was always the possibility Sherlock was doing something important, redecorating, rearranging, and maybe he wouldn’t be able to find where he’d put everything if he were pulled out suddenly. Sherlock had explained the idea of the mind palace to John before—and John found that he caught on surprisingly well, although he still had questions on the finer points of the matter. Sherlock seemed to have a much more elaborate palace than the norm; John had spent some time looking it up, when Sherlock grew too frustrated to answer his inane questions. He had tried making his own—it was a work in progress, and definitely _not_ a palace.

            Maybe he could somehow ease Sherlock out of it.

            “I’m going to touch your feet now,” John said. “Maybe it will help you realize that I need you to wake up.”

            He reached to Sherlock’s feet—his big feet, long as his legs were, and his toes every bit as skinny. John tickled him a little through his stockings—nothing. He grabbed at the toes—also nothing.

            “I’ll try your ankles, now,” he said. Maybe Sherlock would wake up just to tell John to stop touching him. John told himself that he was doing this for a reason—and a very good one, too. He _had_ wanted, sort of, for a while, to kind of…well, to sort of verify Sherlock’s physical existence by touching him; but this wasn’t that. Was Sherlock at all mentally present, right now, anyway? Could he snap awake and tell John, if John started to do something Sherlock didn’t want?  
            John’s hands slid up to Sherlock’s bent knees and rested there for a moment. He squeezed them lightly, checking his breathing, checking his heart rate. “You’re going to feel my hands pass over your midsection,” he said, hoping that this was at least doing _something_ to coax Sherlock out, or he’d feel like a right git, “don’t worry, though, I’m just, er, passing by on my way up.”

            This bit was tricky—John pulled his legs onto the sofa and knelt facing Sherlock, who, with his legs bent, was occupying the other two cushions. John gently parted Sherlock’s legs and placed his hands against Sherlock’s belly. “There, see. Can you feel this at all?”

            Nothing—still—of course. Sherlock _had_ been awfully wound up of late—maybe he was actually sleeping. No, doubtful—his hands were still folded in front of him. He had been thinking, maybe, too hard; with Moriarty at large again, what else was there to do? Sherlock was doubtless dreaming up a way to bring him down—or so John hoped. Sherlock, at least, was done with the games. His demeanor had sobered almost alarmingly since the court case.

            “I have to lean forward now,” John explained to the catatonic detective as he put his weight on his knees and placed his shoulders between Sherlock’s legs to lay a hand against Sherlock’s chest. Heart rate was normal—quick, a bit, maybe, but that was just Sherlock, always quicker than everyone else at everything. “You’re fine, Sherlock. You’re fine. Come out, please.” At what point did one call an ambulance for Sherlock Holmes?

            John breathed in and out slowly, feeling the warmth of Sherlock’s chest on his hand, of his knees on John’s sides as he leaned forward farther. “Sherlock,” he said, and that was all, this time, as he leaned and leaned, and ran out of legs to hold him up, and laid down against Sherlock’s body, chest against chest, touching Sherlock’s face with his hands. “ _Sherlock_.” He licked his lips and considered his options for a moment before tilting his head down and slowly, as slowly as he could muster, as slowly as any human being, he thought, could muster, pressed his lips onto Sherlock’s. “Wake up,” he whispered into Sherlock’s mouth, and then, emboldened, pressed his lips down harder, harder, and licked the insides of Sherlock’s lips, and let his tongue be drawn into Sherlock’s mouth. John wrapped his lips around Sherlock’s in tender nibbles, digging deeper into his mouth until Sherlock stopped being a flatmate or a friend or a patient and started becoming something different, something closer, like a lover, but not. John dug in with his mouth until he had extracted every remnant of the poisonous barbs that tended to take residence on Sherlock’s tongue and scooped them up into his own cheeks, and then swallowed them down deeply, and dug, and dug. Sherlock stopped being a lover and started becoming something else, a glowing center around which John would orbit until it imploded or swallowed him whole. John pulled his lips back and found he didn’t particularly mind which it was, or maybe preferred the swallowing, yes, the swallowing, and he looked down on the glowing center beneath him, and—

Sherlock’s eyes were open.

            “I-I…” John stuttered.

            “Thank you,” said Sherlock, before John could spit out an apology. He laid his hands against John’s, curled over Sherlock’s shoulders.

            “What happened?” John asked softly. “Were you in your mind palace?”

            “I got stuck. I was searching and I got stuck.”

            “How?”

            “I thought I had found a solution,” Sherlock said, his voice quiet, “some sort of peaceful valley, an escape route, the end, the answer. But as I walked through the steps, they brought me back to the same end over and over, a—a miserable one. I was…afraid—paralyzed. It was the only solution. I tried to scramble up the walls surrounding me—to no avail.” He chanced a look at John, and then returned his gaze to his hands as they rested against John’s. “Then something gentle sucked me back up out of it.”

            “Does this happen often?”

            “Not often, no. But now,” this time Sherlock did manage to hold his eyes on John, “you know how to stop it. Thank you.”

            “This is to do with Moriarty, isn’t it?”

            Sherlock was perfectly still; John knew it as a _yes_.

            “Is there anything I can do to help?”

            “Yes,” Sherlock said, and squeezed John’s hands. “Do that again. That…thing.”

            John could only oblige. He could only oblige each day it happened, with increasing frequency. Sherlock refused to say _why_ he got so stuck; John stopped asking. He obliged Sherlock, and dug him free, and held his hands, and sucked the poison from his mouth and from his wounds. John lent Sherlock his mouth and his hands and anything else he could use to draw Sherlock up out of his valleys; he lent him his time and his attention, as if anyone but Sherlock had ever had John’s time and attention in the first place. John lent Sherlock his mouth any time Sherlock asked; any time he didn’t, because when Sherlock got stuck in valleys he was as still as stone and could ask for nothing.

            John lent Sherlock his mouth until Sherlock got stuck in the deepest valley of all, and all John could do was press his lips to the flowers he left there.


End file.
